package com.neusoft.resturant.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.neusoft.resturant.common.utils.PageResult;
import com.neusoft.resturant.common.utils.PageUtils;
import com.neusoft.resturant.entity.ResDishes;
import com.neusoft.resturant.entity.ResShop;
import com.neusoft.resturant.mapper.ResdishesMapper;
import com.neusoft.resturant.service.IResDishesService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 菜品Service业务层处理
 * 
 * @author lzx
 * @date 2023-10-15
 */
@Service
public class ResDishesServiceImpl implements IResDishesService
{

    @Autowired
    private ResdishesMapper resdishesMapper;
    /**
     * 查
     * @param id
     * @return
     */
    public ResDishes selectById(Long id) {
        ResDishes resDishes = resdishesMapper.selectById(id);
        return resDishes;
    }






    /**
     * 分页查询
     */

    @Override
    public PageResult selectResDishList2(ResDishes resDishes, Integer pageNum, Integer pageSize) {
        //1、PageHelper开始分页，传入第几页和每页多少条记录两个参数
        PageHelper.startPage(pageNum, pageSize);
        //2、数据库进行查询
        List<ResDishes> redish = resdishesMapper.selectResDishList(resDishes);
        //3、对返回值进行判断
        if (redish.size()==0){
            return null;
        }
        //4、对查询的结果进行封装
        PageInfo<ResDishes> thumbupPageInfo2 = new PageInfo<>(redish);
        PageResult pageResult2 = PageUtils.getPageResult(thumbupPageInfo2);

        return pageResult2;
    }
}
